/**$Licence:
 *   Use this however/wherever you like, just don't blame me if it breaks anything.
 *   Copyright (C) 2008 - 2013 xingsheng.zhu@gmail.com All rights reserved.
 */
package com.blazemina.config;

import org.apache.mina.core.service.IoHandler;

import com.blazegame.logging.async.AsyncLoggerFactory;
import com.blazegame.logging.log4j.Log4jLoggerFactory;
import com.blazemina.command.CommandFactory;
import com.blazemina.command.DefaultJavaCommandFactory;
import com.blazemina.config.entities.CommandPackages;
import com.blazemina.container.DefaultRequestProcessor;
import com.blazemina.container.RequestProcessor;
import com.blazemina.executor.BlazeminaExecutors;
import com.blazemina.executor.DefaultBlazeminaExecutors;
import com.blazemina.executor.RouteHelper;
import com.blazemina.executor.ThreadpoolBlazeminaExecutors;

/**
 * 配置
 * 
 * @author JackChu
 * @version 2.0.0 2013-2-19 上午11:21:06
 */
public abstract class BlazeminaConfig {

	void init() {

	}

	/**
	 * 配置日志工厂 不配置就直接使用{@link Log4jLoggerFactory} 使用异步日志
	 * {@link AsyncLoggerFactory}
	 */
	public abstract void configLoggerFactory();

	public abstract IoHandler configSocketHandler();

	/**
	 * 配置processor
	 * 
	 * @return
	 */
	public RequestProcessor configRequestProcessor() {
		return new DefaultRequestProcessor();
	}

	/**
	 * 配置command factory 默认使用{@link DefaultJavaCommandFactory},使用java自带的创建类方式
	 * 
	 * 基本spring时，可使用spring来创建
	 * 
	 * @return
	 */
	public CommandFactory configCommandFactory() {
		return new DefaultJavaCommandFactory();
	}

	/**
	 * 配置command package
	 * 
	 * @param packages
	 */
	public abstract void configCommandPackages(CommandPackages packages);

	/**
	 * 配置执行器 {@link DefaultBlazeminaExecutors} 直接调用
	 * {@link ThreadpoolBlazeminaExecutors} 线程池的方式
	 * 
	 * @return
	 */
	public BlazeminaExecutors configExecutor() {
		return new DefaultBlazeminaExecutors();
	}

	/**
	 * 如果使用{@link ThreadpoolBlazeminaExecutors}那必须覆盖此方法,配置线程组
	 * 
	 * @param executors
	 */
	public void configExecutorGroup(BlazeminaExecutors executors) {

	}

	/**
	 * 如果使用{@link ThreadpoolBlazeminaExecutors}那必须覆盖此方法,配置线程组
	 * 
	 * @param executors
	 */
	public RouteHelper configRouteHelper() {
		return null;
	}
}
